<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>岗位申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">

</head>
<body>
<div class="layui-layout layui-layout-admin" style="margin-top: 60px">
    <div class="layui-header layui-bg-blue">
        <div class="layui-logo layui-hide-xs layui-bg-black">高校勤工助学平台</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left" lay-filter="navleft">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs" ><a href="/toQzIndex">首页</a></li>
            <li class="layui-nav-item layui-hide-xs" ><a href="/toGwsqIndex" id="gwsq">岗位申请</a></li>
            <li class="layui-nav-item layui-hide-xs">
                <a href="javascript:;">我的申请</a>
                <dl class="layui-nav-child"> <!-- 二级菜单 -->
                    <dd><a href="/toWdsqIndex">正在申请</a></dd>
                    <dd><a href="/toWdsqIndex1">申请结果</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-hide-xs" ><a href="/toQzCenter" id="grzx">个人中心</a></li>
            <li class="layui-nav-item layui-hide-xs" >
                <a href="javascript:;">联系反馈</a>
                <dl class="layui-nav-child" >
                    <dd><a lay-event="fankui">反馈信息</a></dd>
                    <dd>
                        <a >微信扫一扫</a>
                        <img style="width: 200px;height: 200px;" src="img/公众号1.jpg">
                    </dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right" lay-filter="demo">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//cdn.ilayuis.com/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" tppabs="http://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                    <span id="roleName">用户</span>
                    <i class="layui-icon layui-icon-down layui-nav-more"></i>
                </a>
                <dl class="layui-nav-child">
                    <dd><a lay-event="change">修改密码</a></dd>
                    <dd><a href="/loginOut">退出登录</a></dd>
                </dl>
            </li>
        </ul>
    </div>
</div>

<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
<!--            <legend>信息查询</legend>-->
            <div style="margin: 15px 10px 10px 250px">
                <form class="layui-form layui-form-pane" style="text-aglin:center" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">职位</label>
                            <div class="layui-input-inline">
                                <input type="text" name="p_title" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">招聘单位</label>
                            <div class="layui-input-inline">
                                <input type="text" name="department" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">薪资</label>
                            <div class="layui-input-inline">
                                <input type="text" name="salary" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" ></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="details">详情</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" id="apply" lay-event="apply">申请</a>
        </script>

    </div>
</div>


<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<script src="js/jquery-3.6.3.js"></script>
<script>

    //当页面一加载时就向后台发送post请求,获取当前用户的姓名
    $(function(){
        $.post("../getusername",function(obj){
            $("#roleName").html(obj.name);
        },"json")
    });
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/ListPositions',
            toolbar: '#toolbarDemo',
            even: true,
            defaultToolbar: ['filter','print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
                [
                    {field: 'g_id', width: 200, title: 'ID', sort: true,align:"center"},
                    {field: 'department', width: 200, title: '招聘单位',align:"center"},
                    {field: 'name', width: 100, title: '发布人',align:"center"},
                    {field: 'p_title', width: 200, title: '招聘职位',align:"center"},
                    {field: 'introduce', width: 200, title: '岗位描述',align:"center"},
                    {field: 'salary', width: 200, title: '薪资待遇', sort: true,align:"center"},
                    {field: 'lim', width: 100, title: '招聘人数', sort: true,align:"center"},
                    {field: 'quantity', width: 200, title: '申请通过人数', sort: true,align:"center"},
                    {field: 'time', width: 200, title: '日期',align:"center"},
                    {title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"}
                ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                var result;
                if (this.page.curr) {
                    result = res.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                }
                else {
                    result = res.slice(0, this.limit);
                }
                return {
                    "code": 0, //解析接口状态
                    "msg": '', //解析提示文本
                    "count": res.length, //解析数据长度
                    "data": result //解析数据列表
                };
            }
        });


        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //JSON.stringify(data.field)
            var user = {};
            if (data.field.p_title !== ''){
                user.p_title = data.field.p_title;
            }
            if(data.field.department !== ''){
                user.department = data.field.department;
            }
            if(data.field.salary !== ''){
                user.salary = data.field.salary;
            }
            //执行搜索重载
            table.reload('currentTableId', {
                data:user,
                method:'post',
                url:'/gwsq_search',
                contentType:'application/json;charset=utf-8',
                page: {
                    curr:1
                },
                where:data.field
            }, 'data');

            return false;
        });

        //监听详情、申请
        table.on('tool(currentTableFilter)', function (obj) {
            var data1 = obj.data;
            console.log(data1.g_id);
            if (obj.event === 'details') {
                var index = layer.open({
                    title:false,
                    type: 2,
                    shade: 0.2,
                    maxmin: false,
                    shadeClose: true,
                    area: ['700px', '500px'],
                    content: '/toDetail?id=' + data1.g_id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'apply') {
                var index1 = layer.open({
                    title:"备注",
                    type: 2,
                    shade: 0.2,
                    maxmin: false,
                    shadeClose: true,
                    area: ['600px', '230px'],
                    content: '/toApply?id=' + data1.g_id,
                });
                $(window).on("resize", function () {
                    layer.full(index1);
                });
            }
        })

    });

</script>
<script src="js/nav.js"></script>
</body>
</html>